﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using CoDbObject;
using Colligate.DataSource.DriverTraining;
using SZJT.Utility;

namespace Colligate.DataSource.DriverTraining.Business.Coach
{
    class BusinessCoachInfo : BaseLegoModule
    {
        private const string TABLE_COACH_INFO = "BusinessCoachInfo";

        public BusinessCoachInfo(IDataSourceLayer dataLayer)
            : base(new string[] { TABLE_COACH_INFO }, dataLayer)
        {
        }

        #region 返回Lego模块涉及到的数据名称的结构信息
        /// <summary>
        /// 返回Lego模块涉及到的数据名称的结构信息
        /// </summary>
        /// <param name="strDataName">基础表名称</param>
        /// <returns>表结构信息</returns>
        override public IFieldInfo[] GetStructInfo(string strDataName)
        {
            // 建立IFieldInfo列表
            // CFieldInfo(字段名, 类型, 长度, 索引, 状态, 字段说明, 字段帮助, 显示的格式化字符串, 字段宽度, 关联记录)
            // 类型： text，byte，short，long，single，double，currency，date，logical，memo，binary
            // 索引： 0 无索引，1 重复索引，2 唯一索引，3 关键字段
            // 状态： 0 系统字段，>1显示信息的字段， 2 用于标识记录名称的字段

            IFieldInfo[] tableStructInfo;
            switch (strDataName)
            {
                case TABLE_COACH_INFO:	 // 教练基本信息
                    tableStructInfo = new IFieldInfo[13];
                    tableStructInfo[0] = new CFieldInfo("fCoachGuid", "text", 36, 2, 0, "教练基本信息", "教练基本信息", "", 52, 0);
                    tableStructInfo[1] = new CFieldInfo("fCoachCode", "text", 10, 0, 1, "教练工号", "教练工号", "", 52, 0);
                    tableStructInfo[2] = new CFieldInfo("fCoachName", "text", 20, 0, 1, "教练姓名", "教练姓名", "", 52, 0);
                    tableStructInfo[3] = new CFieldInfo("fCoachID", "text", 18, 0, 1, "教练身份证号，初始密码为身份证号后6位", "教练身份证号，初始密码为身份证号后6位", "", 52, 0);
                    tableStructInfo[4] = new CFieldInfo("fCoachAge", "long", 0, 0, 1, "教练年龄", "教练年龄", "", 52, 0);
                    tableStructInfo[5] = new CFieldInfo("fCoachSex", "text", 2, 0, 1, "教练性别[女|男]", "教练性别[女|男]", "", 52, 0);
                    tableStructInfo[6] = new CFieldInfo("fCoachMobile", "text", 20, 0, 1, "教练手机号", "教练手机号", "", 52, 0);
                    tableStructInfo[7] = new CFieldInfo("fCoachStatus", "text", 10, 0, 1, "教练状态[在岗|离职|停职]", "教练状态[在岗|离职|停职]", "", 52, 0);
                    tableStructInfo[8] = new CFieldInfo("fSchoolGuid", "text", 36, 0, 1, "驾校标识", "驾校标识", "", 52, 0);
                    tableStructInfo[9] = new CFieldInfo("fSchoolName", "text", 50, 0, 1, "驾校名称", "驾校名称", "", 52, 0);
                    tableStructInfo[10] = new CFieldInfo("fCoachAccount", "text", 20, 0, 1, "教练登录帐号", "教练登录帐号", "", 52, 0);
                    tableStructInfo[11] = new CFieldInfo("fCoachMail", "text", 100, 0, 1, "教练邮箱", "教练邮箱", "", 52, 0);
                    tableStructInfo[12] = new CFieldInfo("fCoachPassword", "text", 20, 0, 1, "教练密码", "教练密码", "", 52, 0);
                    break;

                default: tableStructInfo = null; break;
            }
            return tableStructInfo;
        }
        #endregion

        #region 教练信息
        public IDBDataObject GetCoachInfoData(string strDataGuid)
        {
            string tableName = GetStructGlobalName(TABLE_COACH_INFO);
            return DataLayer.GetDBDataObject(tableName, string.Format("fCoachGuid = '{0}'", strDataGuid));
        }

        /// <summary>
        /// 通过查询过滤条件取得教练信息
        /// </summary>
        /// <param name="queryFilter">查询过滤表达式</param>
        /// <returns></returns>
        public IDBBigObjectSet GetCoachListByFilter(string queryFilter)
        {
            return DataLayer.GetDBBigObjectSet(GetStructGlobalName(TABLE_COACH_INFO), queryFilter, "fCoachName");
        }
        #endregion

    }
}
